//删除时先删除子文件与子文件夹，才能删除文件夹
const fs = require('fs');
const path = require('path');

function delDir(filePath){
    if(fs.existsSync(filePath)){
        var files = fs.readdirSync(filePath);
        for(var i = 0;i < files.length;i++){
            var chhildPath = path.join(filePath,'/'+files[i]);
            var fileObj = fs.statSync(chhildPath);
            if(fileObj.isFile()){
                fs.unlinkSync(chhildPath);
            }else if(fileObj.isDirectory){
                delDir(chhildPath);
            }
        }
        fs.rmdirSync(filePath);
    }else{
        console.log("文件路径不存在");
    }
}
var arg = process.argv[2];
var filePath = path.join(__dirname,"/"+arg);
delDir(filePath);